<!DOCTYPE HTML5>
<title>Delayed load of poster should overwrite intrinsic size of video.</title>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<video></video>
<script>
async_test(function(t) {
    var video = document.querySelector("video");

    video.onloadeddata = t.step_func(function() {
        testVideoSize({
            clientWidth: 320,
            clientHeight: 240,
            videoWidth: 320,
            videoHeight: 240,
        });
        video.poster = "content/abe.png";
        var image = document.createElement("img");
        image.src = "content/abe.png";
        image.onload = t.step_func_done(() => testVideoSize({
            clientWidth: 76,
            clientHeight: 103,
            videoWidth: 320,
            videoHeight: 240,
        }));
    });

    function testVideoSize(size) {
        assert_equals(video.clientWidth, size.clientWidth);
        assert_equals(video.clientHeight, size.clientHeight);
        assert_equals(video.videoWidth, size.videoWidth);
        assert_equals(video.videoHeight, size.videoHeight);
    }

    video.src = "content/test.ogv";
});
</script>
